﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.Reflection;
using System.Data;

namespace ConnectionLayer
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in both code and config file together.
    public class DataService : IDataService
    {
        public bool TestConnection()
        {
            return true;
        }

        public Teste[] select(string sql)
        {
            var dt = new DataTable("Kikuti");
            dt.Columns.Add(new DataColumn("fantasy_name"));
            //dt.Rows.Add("Kikuti");
            //dt.Rows.Add("Carlos");
            //dt.Rows.Add("Henrique");
            var a = 0;
            for (var x = 0; x < 7000; x++)
            {
                if (a == 0)
                    dt.Rows.Add("Kikuti" + x);
                else if (a == 1)
                    dt.Rows.Add("Carlos" + x + x);
                else if (a == 2)
                {
                    dt.Rows.Add("Henrique" + x + x + x);
                    a = -1;
                }
                a++;
            }
            return getResult(dt);
        }

        private Teste[] getResult(DataTable dt)
        {
            var arr = new Teste[dt.Rows.Count];
            foreach (DataRow dr in dt.Rows)
                arr[dt.Rows.IndexOf(dr)] = new Teste() { Prop = dr[0].ToString() };
            return arr;
        }

        public Boolean execute(string sql)
        {
            return true;
        }
    }
}
